https://gamehub-lohit.vercel.app
gamehub explorer
Frontend Engineering

gamehub explorer

A scalable web catalog built with React, TypeScript, TanStack Query, and Zustand featuring multi-dimensional filtering, infinite query streams, and client-side CDN image optimization.

GameHub: High-Performance Video Game Discovery and Catalog Architecture

The Core Problem

Online media discovery platforms face an inherent tension between data density and client-side performance. Video game databases aggregate millions of titles, each associated with multi-gigabyte media assets, complex taxonomies (genres, platforms, publishers, Metacritic scores), and search keywords.

When browsing such catalogs, typical web implementations suffer from critical engineering bottlenecks:

  • Combinatorial State Explosion: Combining keyword search, genre filtering, platform selection, and sorting orders often results in race conditions, stale UI renders, and broken back/forward navigation when managed across disjointed component states.
  • Bandwidth and Memory Exhaustion: Game APIs typically link to uncompressed 4K wallpapers and screenshots. Streaming dozens of full-resolution assets onto a client viewport exhausts mobile data limits and leads to browser memory crashes.
  • Cold-Start Network Churn: Fetching static taxonomies (such as genre lists and supported gaming hardware) over the network on every route visit causes jarring layout shifts and skeleton loader flickering.
  • Client and Server State Conflation: Attempting to store asynchronous remote collections inside traditional global stores (such as Redux) results in massive state synchronization overhead and brittle caching logic.

GameHub was engineered to solve these exact friction points, proving that a browser application can deliver instantaneous filtering, smooth infinite scrolling, and rich media exploration without heavy server infrastructure.


The Architectural Solution

The application decouples client interaction state from asynchronous server cache, establishing clean architectural boundaries across the stack.

1. Dual-Engine State Architecture

  • Client State via Zustand: All transient filtering parameters are centralized in a single GameQuery object. Mutators guarantee predictable reset behavior (for example, choosing a genre resets previous search queries to avoid zero-result deadlocks).
  • Server Cache via TanStack Query: All remote data fetching, pagination cursors, deduplication, and caching are managed by TanStack Query. Queries are keyed dynamically off the active GameQuery, giving every unique filter permutation its own independent cache bucket.

2. Strongly-Typed Generic Network Layer

A reusable APIClient<T> class encapsulates Axios requests, configuration parameters, and response envelopes (FetchResponse<T>). React components never directly touch HTTP verbs or configure endpoint URLs.

3. Client-Driven Dynamic Image Pipeline

A lightweight URL-manipulation utility inspects asset URLs and injects dynamic crop and resize parameters (/crop/600/400/) into CDN paths prior to rendering. This guarantees that devices receive properly dimensioned WebP images rather than raw 4K promotional art.


Hardest Technical Obstacles and Engineering Solutions

1. The Multi-Dimensional Filter Race Condition

  • The Challenge: When a user rapidly types in a search input while toggling genres or sorting options, out-of-order network responses can cause the UI to display outdated results or clear valid selections.
  • The Solution: Centralized all query parameters inside a Zustand store with an atomic GameQuery structure. TanStack Query uses this object directly as its query key ['games', gameQuery]. Whenever the store updates, TanStack Query automatically cancels inflight stale requests via AbortController and guarantees that only responses matching the newest query key update the DOM.

2. Media Payload Bloat and Mobile Memory Leaks

  • The Challenge: The RAWG API provides high-resolution promotional artwork that often exceeds 5MB per title. In an infinite-scrolling feed of 100+ titles, a client browser would download over 500MB of imagery, leading to noticeable scroll stutter and high garbage-collection pauses.
  • The Solution: Implemented a string-slicing URL transformer in src/services/image-url.ts that intercepts the CDN endpoint and inserts dimension parameters /crop/600/400/. This slashes average card image transfer from 2MB to approximately 40KB. Combined with local fallback placeholders, it eliminated image-induced frame drops entirely.

3. Cold-Start Layout Shift on Static Taxonomies

  • The Challenge: Displaying loading skeletons for genres and platforms on every cold visit caused layout instability and degraded Core Web Vitals (specifically Cumulative Layout Shift and Largest Contentful Paint).
  • The Solution: Bundled build-time snapshots of platform and genre data and passed them as initialData into useQuery with staleTime: ms('24h'). The sidebar and dropdown menus render synchronously on the first frame with zero network delay, while subsequent updates happen silently in the background if the cache expires.

4. Seamless Infinite Pagination without Layout Thrashing

  • The Challenge: Managing cursor-based pagination alongside dynamic filter changes often causes list resets, duplicate items, or awkward scroll repositioning.
  • The Solution: Leveraged TanStack Query's useInfiniteQuery with getNextPageParam to track the upstream next link. Integrated with react-infinite-scroll-component to monitor scroll thresholds, while preserving previously rendered card nodes and preventing unnecessary re-renders of offscreen elements.

Measurable Performance and Engineering Outcomes

  • Bandwidth Reduction: Reduced total media download footprint by over 80% through dynamic CDN crop slicing.
  • Zero-Flicker Taxonomies: Achieved immediate first-paint rendering of genre lists and platform filters using static initialData cache hydration.
  • Deterministic State: Completely eliminated filter desynchronization bugs and prop-drilling by unifying client state in an atomic Zustand store.
  • Responsive Viewport Support: Dynamic Chakra UI grid templates adapt seamlessly between multi-column desktop layouts (aside main) and thumb-friendly mobile views.

Architecture Takeaways for Developers and Students

  1. 1.
    Keep Client State and Server State Separate: Global state managers like Redux or Zustand are ideal for tracking what the user is doing. Dedicated caching engines like TanStack Query are built for managing what the server knows. Blurring this line is the leading cause of frontend technical debt.
  2. 2.
    Treat Filter Sets as Cohesive Objects: Instead of scattering multiple boolean flags and string states across different components, encapsulate them into a single typed query record. This makes state serializable, testable, and trivial to tie into URL search params or cache keys.
  3. 3.
    Exploit Upstream CDN Capabilities: Before introducing backend compute to process images, explore the transformation parameters supported by modern media CDNs. A 5-line string slicing function can often replace an entire microservice.
HOME✦ABOUT✦PROJECTS✦BLOG✦
>_ READY TO COLLABORATE?

GOT SOME EXCITING IDEAS? LET'S CONNECT AND BUILD SOMETHING EXTRAORDINARY TOGETHER!

lohitkumar1914@gmail.com✦lohitkumar1914@gmail.com✦lohitkumar1914@gmail.com✦lohitkumar1914@gmail.com✦
CLICK TO COPY EMAIL
Designed by Lohit Kumar